package cn.gson.springboot.controller;

import cn.gson.springboot.model.pojos.Department;
import cn.gson.springboot.model.service.DepartmentService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class DepartmentController {
    @Autowired
    DepartmentService deptService;

    @RequestMapping("/dept-all-list")
    @ResponseBody
    //查询所有部门
    public List<Department> findAllDept(){
        return deptService.findAllDept();
    }

    @RequestMapping("/dept-list")
    @ResponseBody
    public List<Department> findDepts(){
        return deptService.findDepts();
    }
    @RequestMapping("/dept")
    @ResponseBody
    public List<Department> findDept(Integer deptId){
        return deptService.findDept(deptId);
    }

    @RequestMapping("/dept-emp-list")
    @ResponseBody
    public List<Department> findDeptEmp(){
        return deptService.findDeptEmp();
    }


    @RequestMapping("/save-dept")
    @ResponseBody
    public void saveDept(@RequestBody Department department){
        deptService.saveDept(department);
    }

    @RequestMapping("/delete-dept")
    @ResponseBody
    public void deleteDept(Integer deptId){
        deptService.deleteDept(deptId);
    }

}
